import React, {Component} from 'react';

import './index.less';

import {getQueryCondition} from '../../../../../hrpub/common/utils/utils';

class SearchModal extends Component {
    constructor(props) {
        super(props);

        this.goSearch = this.goSearch.bind(this);
    }

    goSearch() {
        let data = getQueryCondition(this.props, 'ncc60071025query');

        this.props.updateState({
            searchModalValue: data
        }, () => {
            this.props.getMainTableData();
            this.props.search.openAdvSearch('ncc60071025query', false);
        });
    }

    render() {
        const {
            search,
            queryOid,
            searchModalVisible
        } = this.props;

        return (
            <div style={{
                display: searchModalVisible ? 'block' : 'none'
            }}>
                {search.NCCreateSearch('ncc60071025query', {
                    clickSearchBtn: this.goSearch,
                    onlyShowAdvArea: false,
                    showAdvSearchPlanBtn: true,
                    saveSearchPlan: true,
                    // oid: queryOid,
                    // oid: this.props.queryOid,
                    onlyShowSuperBtn: true
                })}
            </div>
        );
    }
}

export default SearchModal;
